<template>
  <div class="tb">
    <mt-field
      label="其他燃料类型名称:"
      placeholder="请输入"
      readonly=true
      type="text"
      v-model="rlTags.name"
      @click.native.capture="choseHwzl"
    ></mt-field>
    <mt-field label="对应车牌号码:" placeholder="请输入" readonly=true type="text" v-model="vehicleNo"></mt-field>
    <div class="button">
      <mt-button type="primary" size="large" @click="check">确定</mt-button>
    </div>
    <mt-popup
      v-model="popupVisible"
      popup-transition="popup-fade"
      closeOnClickModal="true"
      position="bottom"
    >
      <mt-picker :slots="slots" showToolbar ref="picker" value-key="name">
        <div class="picker-toolbar-title">
          <div class="usi-btn-cancel" @click="popupVisible = !popupVisible">取消</div>
          <div class>请选择燃料类型</div>
          <div class="usi-btn-sure" @click="handleConfig">确定</div>
        </div>
      </mt-picker>
    </mt-popup>
  </div>
</template>
    
    <script>
import { Field } from "mint-ui";
import { Picker } from "mint-ui";
import { Popup } from "mint-ui";
import { Toast } from "mint-ui";

export default {
  data() {
    return {
      recid: "",
      yhmlk: "",
      companyType: "", // 企业类型
      vehicleNo: "", // 车牌号码
      plateColorCode: "", //车辆颜色
      fzdcbfd72019001: "",
      fzdcbfd72019002: "",
      rlTags: {},
      userInfo: {},
      //
      showToolbar: true,
      slots: [
        {
          values: []
        }
      ],
      popupVisible: false
    };
  },
  watch: {},
  created() {
    this.userInfo = JSON.parse(localStorage.getItem("userInfo") || {});
    this.vehicleNo = this.userInfo.vehicleNo;
  },
  mounted() {},
  methods: {
    // 校验条件
    check() {
      if (this.fzdcbfd72019001 == "") {
        Toast("其他燃料类型名称不能为空！");
      } else if (this.vehicleNo == "") {
        Toast("对应车牌号码不能为空！");
      } else {
        this.commit();
      }
    },
    commit() {
      let data = {};
      data.vehicleNo = this.userInfo.vehicleNo;
      data.plateColorCode = this.userInfo.plateColorCode;
      data.companyType = this.userInfo.companyType;
      let fzdcbfd07 = {};
      (fzdcbfd07.recid = this.recid),
        (fzdcbfd07.yhmlk = this.userInfo.yhRecid),
        (fzdcbfd07.fzdcbfd72019001 = this.rlTags.code),
        (fzdcbfd07.fzdcbfd72019002 = this.userInfo.vehicleNo),
        (data.fzdcbfd07 = fzdcbfd07),
        console.log("辅助表5-其他" + JSON.stringify(data));
      this.axios
        .post(
          "http://zxdc.catsic.com:9090/sampling/sjAssit/saveFzdcbfd07ForSJ",
          { data: data },
          {
            headers: {
              "Content-Type": "application/json",
              mobileHeader:
                '{"sessionId":' + localStorage.getItem("sessionId") + "}"
            }
          }
        )
        .then(
          result => {
            console.log(result)
            if (result.data.status == "1000") {
              console.log("保存成功");
              console.log(result);
              this.goback();
            } else {
              Toast(result.data.MSG);
            }
          },
          error => {
            console.log("getyhcars request error:" + error);
          }
        );
    },

    // 选择货物种类
    choseHwzl() {
      this.$http.get("http://zxdc.catsic.com:9090/sampling/json/carTyps").then(
        response => {
          this.slots[0].values = response.body.fuleType;
          this.popupVisible = true;
        },
        response => {
          console.log("数据加载失败");
        }
      );
    },
    // 弹出框点击确定按钮点击事件 add by qzn 20190627
    handleConfig: function() {
      this.currentTags = this.$refs.picker.getValues()[0];
      console.log('currr-->>'+JSON.stringify(this.currentTags))
      this.rlTags = this.currentTags;
      this.fzdcbfd72019001 = this.currentTags.code;
      this.popupVisible = false;
    },
    goback() {
      this.$router.go(-1);
    }
  },
  mounted() {},
  updated: function() {}
};
</script>
    
    <style lang="scss" scoped>
.tb {
  padding-top: 10px;
}

.mint-cell {
  background-color: #efeff4;
}
input[type="number"] {
  line-height: 21px;
  width: 100%;
  height: 40px;
  margin-bottom: 0px;
  padding: 10px 15px;
  -webkit-user-select: text;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  outline: 0;
  background-color: #fff;
  -webkit-appearance: none;
}
.button {
  padding-top: 3%;
  padding-left: 5%;
  padding-right: 5%;
  padding-bottom: 5%;
}
.picker-toolbar-title {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  height: 200px;
  line-height: 40px;
  font-size: 16px;
  width: 100%;
}
.usi-btn-cancel,
.usi-btn-sure {
  color: #26a2ff;
}
.mint-popup-bottom {
  width: 100%;
  top: auto;
  right: auto;
  bottom: 0;
}
</style>